
package com.device.idea.wbservicesdk.demo.sdkInit;

import android.content.ComponentName;
import android.content.Context;
import android.util.Log;

import com.device.idea.wbservicesdk.demo.WbServiceDemoActivity;
import com.device.idea.whiteboardservicesdk.Callback;
import com.device.idea.whiteboardservicesdk.CloseCallback;
import com.device.idea.whiteboardservicesdk.IWhiteboardAppEventHandler;
import com.device.idea.whiteboardservicesdk.WhiteboardAppController;
import com.device.idea.whiteboardservicesdk.entity.AppInfo;

/**
 * Author: xurui 30031276
 * Created on 2023/03/064 10:18
 * Desc：
 */
public class SdkPresenter {
    private static final String TAG = SdkPresenter.class.getSimpleName();

    private static WhiteboardAppController whiteboardAppController;

    private static WbServiceDemoActivity uiInstance;

    public static void setUiInstance(WbServiceDemoActivity homeActivity) {
        uiInstance = homeActivity;
    }

    /**
     * 初始化SDK
     *
     * @param
     * @return
     */
    public static void initSdkController(Context context, AppInfo appInfo,
        IWhiteboardAppEventHandler iWhiteboardAppEventHandler) {
        if (whiteboardAppController == null) {
            whiteboardAppController = WhiteboardAppController.create(context, appInfo, iWhiteboardAppEventHandler);
        }
    }

    /**
     * 去初始化SDK
     */
    public static void destroy() {
        if (whiteboardAppController != null) {
            WhiteboardAppController.destroy();
            whiteboardAppController = null;
        }
    }

    /**
     * 打开标注
     */
    public static void openAnnotation(Callback callback) {
        whiteboardAppController.openAnnotation(callback);
    }

    /**
     * 关闭标注
     *
     * @param componentName 白板服务的componentName
     */
    public static void closeBoard(ComponentName componentName, CloseCallback callback) {
        whiteboardAppController.closeBoard(componentName, callback);
    }

    /**
     * 获取版本信息
     *
     * @return String
     */
    public static String getSdkVersion() {
        Log.i(TAG, "getVersion success");
        return WhiteboardAppController.getSdkVersion();
    }

    /**
     * 获取服务版本信息
     *
     * @return String
     */
    public static String getServerVersion() {
        Log.i(TAG, "getServiceVersion success");
        return whiteboardAppController.getServerVersion();
    }

    /**
     * 获取平台版本信息
     *
     * @return String
     */
    public static String getPlatformVersion() {
        Log.i(TAG, "getPlatformVersion success");
        return whiteboardAppController.getPlatformVersion();
    }
}
